<?php

declare(strict_types=1);

namespace Plugin\Attractions\Broadcast\Task;

use Common\Common;
use Hyperf\Crontab\Annotation\Crontab;
use Plugin\Attractions\Broadcast\Repository\Broadcast_plans\BroadcastPlansRepository;

#[Crontab(name: 'init-broadcast-execution-count', 
    rule: '0 0 * * *', 
    memo: '初始化每日广播执行次数', 
    callback: 'execute', 
    enable: [InitBroadcastExecitionCount::class, 'isEnable'])]
class InitBroadcastExecitionCount
{
    public function execute()
    {
        Common::log(__CLASS__, '执行初始化每日广播执行次数定时任务');
        Common::container()->get(BroadcastPlansRepository::class)->initExecutionCount();
    }

    public function isEnable(): bool
    {
        return env('ENABLE_CRON');
    }
}